package com.hengtongxing.hejiayun.homepage;


import android.os.Bundle;
import android.text.TextUtils;
import android.widget.EditText;
import android.widget.TextView;

import com.hengtongxing.hejiayun.R;
import com.hengtongxing.hejiayun.base.BaseActivity;
import com.hengtongxing.hejiayun.base.DataCallBack;
import com.hengtongxing.hejiayun.bean.BaseResponseBean;
import com.hengtongxing.hejiayun.event.OrderRefushEvent;
import com.hengtongxing.hejiayun.homepage.model.HomePageModelImpl;
import com.hengtongxing.hejiayun.utils.ToastUtil;
import com.hengtongxing.hejiayun.widget.AppTitleBar;

import org.greenrobot.eventbus.EventBus;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class CleanEvaluateActivity extends BaseActivity {

    @BindView(R.id.title_bar)
    AppTitleBar titleBar;
    @BindView(R.id.edit_content)
    EditText editContent;
    @BindView(R.id.tv_commit)
    TextView tvCommit;
    private String id;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_clean_evaluate);
        ButterKnife.bind(this);
        initView();
    }

    public void initView() {
        id = getIntent().getStringExtra("id");

    }

    @OnClick(R.id.tv_commit)
    public void onViewClicked() {
        String comment = editContent.getText().toString();
        if (TextUtils.isEmpty(comment)) {
            ToastUtil.showShort("请输入您的评价内容");
            return;
        }
        requestKeepingComment(comment);
    }

    public void requestKeepingComment(String comment) {
        new HomePageModelImpl().requestKeepingComment(id, comment, new DataCallBack<BaseResponseBean>() {
            @Override
            public void onSuccessful(BaseResponseBean bean) {
                ToastUtil.showShort("评价成功");
                EventBus.getDefault().post(new OrderRefushEvent());
                finish();
            }

            @Override
            public void onFailed(String msg, String code) {

            }
        });
    }
}
